<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./iconfont/iconfont.css">
    <link rel="stylesheet" href="./index.css">
</head>
<div id="wrapper">

</div>

<body>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script>


        var $Div = $('#wrapper');
        var logistics;
        var isShow = [false, false, false, false];
        var pro = function (url, type, data) {
            console.log(url, type, data)
            return new Promise(function (resolve, reject) {
                $.ajax({
                    xhrFields: {
                        withCredentials: true
                    },
                    url,
                    type,
                    data,
                    success: function (res) {
                        resolve(res)
                    }
                })
            })
        }
        pro('http://127.0.0.1:5001/api/login', 'POST', {
            username: 'dafeige',
            password: '123456'
        }).then(function (res) {
            if (res.status === 1) {
                return pro('http://127.0.0.1:5001/api/getIndent', 'GET');
            } else {
                alert(res.msg)
            }
        }).then(function (res) {
            if (res.status === 1) {
                $.each(res.data, function (index, ele) {
                    var tempTime = ele.createdAt.split('T');
                    var time = tempTime[0] + ' ' + tempTime[1].substr(0, tempTime[1].indexOf('.'));
                    var $Li = $('<li class="item"></li>');
                    var $DivLog = $('<div class="log_wrapper"></div>');
                    var $Img = $('<img class="item_img" src="' + ele.imgUrl + '"></img>');
                    var $Btn = $('<div class="logistics">物流信息<p class="btn iconfont icon-xia"></p></div>');
                    $Btn.data('id', ele.ordersId);
                    var $Details = $(`<div class="item_details">
                    <p class="name"> ${ele.name} </p>
                    <p class="target_site"> 收货地址： ${ele.targetSite} </p>
                    <p class="price"> <span>价格:</span> <span>${ele.price} x ${ele.num} </span></p>
                    <p class="time"> ${time} </p>
                    </div>`);
                    $Li.append($Img).append($Details).append($Btn);
                    $Div.append($Li);
                    $Div.append($DivLog);
                });
                $('.logistics').each(function (index, item) {
                    
                });
            } else {
                alert(res.msg)
            }
        })



    </script>
</body>

</html>